import mockjs from "mockjs";

const loginAction = () => {
  return {
    msg: "操作成功",
    code: 200,
    token:
      "eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6IjgyZmZkZDJkLTI2YjctNDhmYS1iOTU2LTRlMjhhZGExNTI1ZSJ9.gG_cB-8fA-b0cOdQckJDypnyy15LyIZWXuHuU8dE-7J5mFBi3-vBXMCTbqurLsR8fvJwY9lWnjZ_6yiSRFWD7w",
  };
};

const captchaImageAction = () => {
  return { msg: "操作成功", code: 200, captchaEnabled: false };
};

const getInfoAction = () => {
  return {
    msg: "操作成功",
    code: 200,
    permissions: [
      "screen:add",
      "map:view",
      "file:view",
      "dataset:label",
      "datasource:view",
      "file:download",
      "component:view",
      "map:update",
      "component:update",
      "component:add",
      "datasource:add",
      "map:add",
      "dataset:execute",
      "screen:view",
      "dataset:update",
      "dataset:category",
      "datasource:update",
      "screen:update",
      "dataset:add",
      "file:upload",
      "datasource:test",
      "dataset:view",
    ],
    roles: ["common"],
    user: {
      createBy: "admin",
      createTime: "2024-11-05 11:25:11",
      updateBy: null,
      updateTime: null,
      remark: null,
      params: {
        "@type": "java.util.HashMap",
      },
      userId: 7,
      deptId: null,
      userName: "Test",
      nickName: "Test",
      email: null,
      phonenumber: null,
      sex: "0",
      avatar:
        "/profile/avatar/2024/11/05/1666271025786007553_20241105112558A001.png",
      password: "$2a$10$bR4.uPKDsxfRfhZbm/i.8ejqm64A6baNqB2DEzhyei.KqNpSKa1Tq",
      status: "0",
      delFlag: "0",
      loginIp: "223.11.8.203",
      loginDate: "2024-12-03T16:10:34.000+08:00",
      dept: null,
      roles: [
        {
          createBy: null,
          createTime: null,
          updateBy: null,
          updateTime: null,
          remark: null,
          params: {
            "@type": "java.util.HashMap",
          },
          roleId: 2,
          roleName: "超级无敌VIP",
          roleKey: "common",
          roleSort: 2,
          dataScope: "2",
          menuCheckStrictly: false,
          deptCheckStrictly: false,
          status: "0",
          delFlag: null,
          flag: false,
          menuIds: null,
          deptIds: null,
          permissions: [
            "screen:add",
            "map:view",
            "file:view",
            "dataset:label",
            "datasource:view",
            "file:download",
            "component:view",
            "map:update",
            "component:update",
            "component:add",
            "datasource:add",
            "map:add",
            "dataset:execute",
            "screen:view",
            "dataset:update",
            "dataset:category",
            "datasource:update",
            "screen:update",
            "dataset:add",
            "file:upload",
            "datasource:test",
            "dataset:view",
          ],
          admin: false,
        },
      ],
      roleIds: null,
      postIds: null,
      roleId: null,
      admin: false,
    },
  };
};

const getRoutersAction = () => {
  return {
    msg: "操作成功",
    code: 200,
    data: [],
  };
};

const bigScreenCatalogAction = () => {
  console.log("bigScreenCatalogAction");
  return {
    code: 200,
    msg: null,
    data: [
      {
        id: "8",
        name: "3D 可视化",
        code: "bigScreenCatalog_CohqfjcVAk",
        type: "bigScreenCatalog",
        orderNum: 0,
      },
      {
        id: "6",
        name: "2D 可视化",
        code: "bigScreenCatalog_rgpPDdkBMY",
        type: "bigScreenCatalog",
        orderNum: 1,
      },
      {
        id: "7",
        name: "组态",
        code: "bigScreenCatalog_TOkD4dkuqb",
        type: "bigScreenCatalog",
        orderNum: 2,
      },
      {
        id: "13",
        name: "测试098",
        code: "bigScreenCatalog_SqsOZNAXlV",
        type: "bigScreenCatalog",
        orderNum: 4,
      },
    ],
  };
};

const designPageAction = () => {
  console.log("dddddddddd");
  return {
    code: 200,
    msg: null,
    data: {
      className: "com.gccloud.common.vo.PageVO",
      totalCount: 134,
      size: 10,
      totalPage: 14,
      current: 1,
      list: [
        {
          id: "1852635891082645694",
          createDate: null,
          updateDate: "2024-12-03T14:13:16.000+08:00",
          createBy: null,
          updateBy: null,
          delFlag: 0,
          name: "888888",
          code: "bigScreen_A6pZGVGsmr",
          parentCode: "",
          type: null,
          coverPicture: "cover/bigScreen_A6pZGVGsmr.png",
          config: null,
          remark: null,
          orderNum: 0,
          appCode: "",
        },
        {
          id: "1852635891082645693",
          createDate: null,
          updateDate: "2024-12-03T14:07:49.000+08:00",
          createBy: null,
          updateBy: null,
          delFlag: 0,
          name: "22233341321",
          code: "bigScreen_6OZUX7jRWd",
          parentCode: "",
          type: null,
          coverPicture: "",
          config: null,
          remark: null,
          orderNum: 0,
          appCode: "",
        },
        {
          id: "1852635891082645692",
          createDate: null,
          updateDate: "2024-12-03T13:57:08.000+08:00",
          createBy: null,
          updateBy: null,
          delFlag: 0,
          name: "wer",
          code: "bigScreen_PVHBWMR13x",
          parentCode: "bigScreenCatalog_SqsOZNAXlV",
          type: null,
          coverPicture: "cover/bigScreen_PVHBWMR13x.png",
          config: null,
          remark: null,
          orderNum: 0,
          appCode: "",
        },
        {
          id: "1852635891082645690",
          createDate: null,
          updateDate: "2024-12-03T11:28:27.000+08:00",
          createBy: null,
          updateBy: null,
          delFlag: 0,
          name: "MQTT测试-组态",
          code: "bigScreen_TME5dv3upC",
          parentCode: "bigScreenCatalog_TOkD4dkuqb",
          type: null,
          coverPicture: "cover/bigScreen_TME5dv3upC.png",
          config: null,
          remark: null,
          orderNum: 0,
          appCode: "",
        },
        {
          id: "1852635891082645689",
          createDate: null,
          updateDate: "2024-12-03T11:15:54.000+08:00",
          createBy: null,
          updateBy: null,
          delFlag: 0,
          name: "MQTT测试",
          code: "bigScreen_6JncqS9v96",
          parentCode: "bigScreenCatalog_TOkD4dkuqb",
          type: null,
          coverPicture: "cover/bigScreen_6JncqS9v96.png",
          config: null,
          remark: null,
          orderNum: 0,
          appCode: "",
        },
        {
          id: "1852635891082645688",
          createDate: null,
          updateDate: "2024-12-03T10:24:14.000+08:00",
          createBy: null,
          updateBy: null,
          delFlag: 0,
          name: "test123654636666",
          code: "bigScreen_47117wmpJu",
          parentCode: "bigScreenCatalog_CohqfjcVAk",
          type: null,
          coverPicture: "",
          config: null,
          remark: null,
          orderNum: 0,
          appCode: "",
        },
        {
          id: "1852635891082645687",
          createDate: null,
          updateDate: "2024-12-03T09:49:02.000+08:00",
          createBy: null,
          updateBy: null,
          delFlag: 0,
          name: "11111111111",
          code: "bigScreen_Jalz1LzWJz",
          parentCode: "",
          type: null,
          coverPicture: "",
          config: null,
          remark: null,
          orderNum: 0,
          appCode: "",
        },
        {
          id: "1852635891082645685",
          createDate: null,
          updateDate: "2024-12-03T09:28:35.000+08:00",
          createBy: null,
          updateBy: null,
          delFlag: 0,
          name: "1234",
          code: "bigScreen_shyoOUKj2u",
          parentCode: "",
          type: null,
          coverPicture: "",
          config: null,
          remark: null,
          orderNum: 0,
          appCode: "",
        },
        {
          id: "1852635891082645684",
          createDate: null,
          updateDate: "2024-12-02T23:15:28.000+08:00",
          createBy: null,
          updateBy: null,
          delFlag: 0,
          name: "test2222",
          code: "bigScreen_IYfL0erUHP",
          parentCode: "bigScreenCatalog_CohqfjcVAk",
          type: null,
          coverPicture: "",
          config: null,
          remark: null,
          orderNum: 0,
          appCode: "",
        },
        {
          id: "1852635891082645683",
          createDate: null,
          updateDate: "2024-12-02T16:24:47.000+08:00",
          createBy: null,
          updateBy: null,
          delFlag: 0,
          name: "测试ASD",
          code: "bigScreen_12roQ7agxL",
          parentCode: "bigScreenCatalog_rgpPDdkBMY",
          type: null,
          coverPicture: "cover/bigScreen_12roQ7agxL.png",
          config: null,
          remark: null,
          orderNum: 0,
          appCode: "",
        },
      ],
    },
  };
};

const logoutAction = () => {
  return {
    code: 200,
    data: null,
    msg: "退出成功",
  };
};

const nameRepeatAction = () => {
  return {
    code: 200,
    msg: null,
    data: false,
  };
};

const resourceCatalogAction = () => {
  return {
    code: 200,
    msg: null,
    data: [
      {
        id: "5",
        name: "SVG资源",
        code: "resourceCatalog_q6w1Au59mz",
        type: "resourceCatalog",
        orderNum: 0,
      },
      {
        id: "4",
        name: "装饰图",
        code: "resourceCatalog_Mye2GLftru",
        type: "resourceCatalog",
        orderNum: 0,
      },
      {
        id: "3",
        name: "背景图",
        code: "resourceCatalog_7v23UQYEc0",
        type: "resourceCatalog",
        orderNum: 0,
      },
      {
        id: "2",
        name: "2D图标",
        code: "resourceCatalog_PSaaHjbTS3",
        type: "resourceCatalog",
        orderNum: 0,
      },
      {
        id: "1",
        name: "3D图标",
        code: "resourceCatalog_WnQBKdjgMY",
        type: "resourceCatalog",
        orderNum: 0,
      },
    ],
  };
};

const fileAction = () => {
  return {
    code: 200,
    msg: null,
    data: {
      totalCount: 321,
      size: 10,
      totalPage: 33,
      current: 1,
      list: [
        {
          id: "330",
          createDate: "2024-12-03T14:15:45.000+08:00",
          updateDate: "2024-12-03T14:15:45.000+08:00",
          createBy: "Test",
          updateBy: "Test",
          delFlag: 0,
          module: "resourceCatalog_PSaaHjbTS3",
          originalName: "LOGO标志.png",
          newName: "1863829454577598465.png",
          extension: "png",
          path: "/www/wwwroot/JavaProject/A-SiWu-IoT/uploadPath",
          url: "/1863829454577598465.png",
          size: 3204,
          downloadCount: 0,
          userName: "",
          bucket: "gc-starter",
          space: "3.2 KB",
        },
        {
          id: "329",
          createDate: "2024-12-03T10:34:02.000+08:00",
          updateDate: "2024-12-03T10:34:02.000+08:00",
          createBy: "Test",
          updateBy: "Test",
          delFlag: 0,
          module: "attachment",
          originalName: "5.jpg",
          newName: "1863773658850406402.jpg",
          extension: "jpg",
          path: "/www/wwwroot/JavaProject/A-SiWu-IoT/uploadPath",
          url: "/1863773658850406402.jpg",
          size: 15223,
          downloadCount: 0,
          userName: "",
          bucket: "gc-starter",
          space: "15.22 KB",
        },
        {
          id: "328",
          createDate: "2024-11-28T18:10:04.000+08:00",
          updateDate: "2024-11-28T18:10:04.000+08:00",
          createBy: "Test",
          updateBy: "Test",
          delFlag: 0,
          module: "resourceCatalog_q6w1Au59mz",
          originalName: "首页.png",
          newName: "1862076483716132866.png",
          extension: "png",
          path: "/www/wwwroot/JavaProject/A-SiWu-IoT/uploadPath",
          url: "/1862076483716132866.png",
          size: 616116,
          downloadCount: 1,
          userName: "",
          bucket: "gc-starter",
          space: "616.12 KB",
        },
        {
          id: "327",
          createDate: "2024-11-28T16:49:45.000+08:00",
          updateDate: "2024-11-28T16:49:45.000+08:00",
          createBy: "Test",
          updateBy: "Test",
          delFlag: 0,
          module: "null",
          originalName: "iShot_2024-11-28_16.49.15.png",
          newName: "1862056271440654337.png",
          extension: "png",
          path: "/www/wwwroot/JavaProject/A-SiWu-IoT/uploadPath",
          url: "/1862056271440654337.png",
          size: 151832,
          downloadCount: 0,
          userName: "",
          bucket: "gc-starter",
          space: "151.83 KB",
        },
        {
          id: "326",
          createDate: "2024-11-28T16:46:26.000+08:00",
          updateDate: "2024-11-28T16:46:26.000+08:00",
          createBy: "Test",
          updateBy: "Test",
          delFlag: 0,
          module: "resourceCatalog_7v23UQYEc0",
          originalName: "iShot_2024-11-28_16.45.56.png",
          newName: "1862055438397353986.png",
          extension: "png",
          path: "/www/wwwroot/JavaProject/A-SiWu-IoT/uploadPath",
          url: "/1862055438397353986.png",
          size: 98711,
          downloadCount: 0,
          userName: "",
          bucket: "gc-starter",
          space: "98.71 KB",
        },
        {
          id: "325",
          createDate: "2024-11-28T16:46:20.000+08:00",
          updateDate: "2024-11-28T16:46:20.000+08:00",
          createBy: "Test",
          updateBy: "Test",
          delFlag: 0,
          module: "resourceCatalog_7v23UQYEc0",
          originalName: "iShot_2024-11-28_16.45.47.png",
          newName: "1862055411692220417.png",
          extension: "png",
          path: "/www/wwwroot/JavaProject/A-SiWu-IoT/uploadPath",
          url: "/1862055411692220417.png",
          size: 475392,
          downloadCount: 0,
          userName: "",
          bucket: "gc-starter",
          space: "475.39 KB",
        },
        {
          id: "324",
          createDate: "2024-11-28T16:45:28.000+08:00",
          updateDate: "2024-11-28T16:45:28.000+08:00",
          createBy: "Test",
          updateBy: "Test",
          delFlag: 0,
          module: "resourceCatalog_7v23UQYEc0",
          originalName: "iShot_2024-11-28_16.44.00.png",
          newName: "1862055194326609921.png",
          extension: "png",
          path: "/www/wwwroot/JavaProject/A-SiWu-IoT/uploadPath",
          url: "/1862055194326609921.png",
          size: 361284,
          downloadCount: 0,
          userName: "",
          bucket: "gc-starter",
          space: "361.28 KB",
        },
        {
          id: "323",
          createDate: "2024-11-28T16:44:32.000+08:00",
          updateDate: "2024-11-28T16:44:32.000+08:00",
          createBy: "Test",
          updateBy: "Test",
          delFlag: 0,
          module: "form",
          originalName: "iShot_2024-11-28_16.44.00.png",
          newName: "1862054958258597889.png",
          extension: "png",
          path: "/www/wwwroot/JavaProject/A-SiWu-IoT/uploadPath",
          url: "/1862054958258597889.png",
          size: 361284,
          downloadCount: 4,
          userName: "",
          bucket: "gc-starter",
          space: "361.28 KB",
        },
        {
          id: "322",
          createDate: "2024-11-28T16:22:44.000+08:00",
          updateDate: "2024-11-28T16:22:44.000+08:00",
          createBy: "Test",
          updateBy: "Test",
          delFlag: 0,
          module: "form",
          originalName: "iShot_2024-11-28_16.21.56.png",
          newName: "1862049473824436226.png",
          extension: "png",
          path: "/www/wwwroot/JavaProject/A-SiWu-IoT/uploadPath",
          url: "/1862049473824436226.png",
          size: 4377,
          downloadCount: 0,
          userName: "",
          bucket: "gc-starter",
          space: "4.38 KB",
        },
        {
          id: "321",
          createDate: "2024-11-28T16:20:45.000+08:00",
          updateDate: "2024-11-28T16:20:45.000+08:00",
          createBy: "Test",
          updateBy: "Test",
          delFlag: 0,
          module: "form",
          originalName: "背景.jpeg",
          newName: "1862048971548143618.jpeg",
          extension: "jpeg",
          path: "/www/wwwroot/JavaProject/A-SiWu-IoT/uploadPath",
          url: "/1862048971548143618.jpeg",
          size: 12148,
          downloadCount: 0,
          userName: "",
          bucket: "gc-starter",
          space: "12.15 KB",
        },
      ],
    },
  };
};

const addDesignAction = () => {
  return { code: 200, msg: null, data: "bigScreen_lxlrujvXkz" };
};

const checkPermissionAction = () => {
  return { code: 200, msg: null, data: true };
};

const designInfoCode = () => {
  return {
    code: 200,
    msg: null,
    data: {
      className: "com.gccloud.dataroom.core.module.manage.dto.DataRoomPageDTO",
      appCode: "",
      id: "1852635891082645707",
      name: "门户-副本",
      code: "bigScreen_oI3roGjO5k",
      icon: "00dataSourceSet",
      coverPicture: "cover/bigScreen_oI3roGjO5k.png",
      iconColor: "#007aff",
      orderNum: 0,
      remark: "",
      style: "",
      parentCode: "bigScreenCatalog_rgpPDdkBMY",
      chartList: [
        {
          name: "文本",
          title: "文本",
          icon: "00LcdpText",
          className:
            "com.gccloud.dataroom.core.module.chart.components.ScreenTextChart",
          w: 200,
          h: 60,
          x: 149,
          y: 107,
          type: "texts",
          border: {
            type: "",
            titleHeight: 60,
            fontSize: 30,
            isTitle: true,
            padding: [0, 0, 0, 0],
          },
          option: {
            theme: "dark",
            data: [],
            text: "文本标签占位符",
            displayOption: {
              serverPagination: {
                enable: false,
              },
              pageSize: {
                enable: false,
              },
              metricField: {
                label: "指标",
                enable: true,
                multiple: false,
              },
              dimensionField: {
                label: "维度",
                enable: false,
                multiple: true,
              },
              dimensionList: {
                label: "维度",
                enable: false,
                multiple: true,
              },
              seriesField: {
                enable: false,
                required: true,
              },
              dataAllocation: {
                enable: true,
              },
              params: {
                enable: true,
              },
              dataSourceType: {
                enable: true,
              },
              text: {
                label: "文本内容",
                enable: true,
              },
              expression: {
                label: "表达式",
                enable: true,
              },
            },
          },
          z: 0,
          locked: false,
          group: "",
          code: "eftxXtnj",
          showTitle: true,
          version: "2023111401",
          url: "https://www.runoob.com/",
          expression: "return ",
          expressionCodes: [],
          rotateX: 0,
          rotateY: 0,
          rotateZ: 0,
          perspective: 0,
          skewX: 0,
          skewY: 0,
          dataSource: {
            className:
              "com.gccloud.dataroom.core.module.chart.components.datasource.DataSetDataSource",
            dataSourceKey: "",
            source: "dataset",
            businessKey: "",
            dimensionField: "",
            metricField: "",
            seriesField: "",
            dimensionFieldList: [],
            metricFieldList: [],
            seriesFieldList: [],
            serverPagination: false,
            pageSize: 10,
            params: {},
            dataSetType: "1",
            formCode: "",
          },
          customize: {
            title: "文本标签占位符",
            fontSize: 20,
            fontWeight: 700,
            fontFamily: "",
            color: "left,#ffffff,#ffffff",
            align: "center",
            letterSpacing: 1,
          },
          inParams: [],
          linkage: {
            action: {
              type: "js",
              script: "",
            },
            components: [],
          },
          filterList: [],
          dataFlag: false,
          offsetX: 103,
          offsetY: 78,
          width: 144,
          height: 144,
          key: "eftxXtnj",
          theme: {
            dark: {
              color: "left,#ffffff,#ffffff",
            },
            light: {
              color: "left,#ffffff,#ffffff",
            },
          },
          loading: true,
        },
      ],
      type: "bigScreen",
      pageConfig: {
        w: 1920,
        h: 1080,
        bgColor: "#151a26",
        lightBgColor: "rgba(15, 105, 239, 1)",
        bg: null,
        lightBg: null,
        customTheme: "light",
        opacity: 100,
        cacheDataSets: [],
        fitMode: "auto",
        refreshConfig: [],
      },
      isPreview: true,
    },
  };
};

const chartDataChartAction = () => {
  return {
    code: 200,
    msg: null,
    data: {
      success: false,
      executionByFrontend: false,
      data: [
        {
          title: "文本标签占位符",
        },
      ],
      totalCount: 0,
      totalPage: 0,
      sql: null,
      columnData: {
        title: {
          type: "varchar",
          tableName: "",
          originalColumn: "title",
          aggregate: "",
          alias: "title",
          remark: "标题",
        },
      },
    },
  };
};

const chartDataListAction = () => {
  return {
    code: 200,
    msg: null,
    data: {
      success: false,
      executionByFrontend: false,
      data: null,
      totalCount: 0,
      totalPage: 0,
      sql: null,
      columnData: null,
    },
  };
};

mockjs.mock("/prod-api/login", "post", loginAction);
mockjs.mock("/prod-api/captchaImage", "get", captchaImageAction);
mockjs.mock("/prod-api/getInfo", "get", getInfoAction);
mockjs.mock("/prod-api/getRouters", "get", getRoutersAction);
mockjs.mock(
  "/prod-api/bigScreen/type/list/bigScreenCatalog",
  "get",
  bigScreenCatalogAction
);

mockjs.mock("/prod-api/bigScreen/design/page", "get", designPageAction);
mockjs.mock("/prod-api/bigScreen/file", "get", fileAction);

mockjs.mock("/prod-api/logout", "post", logoutAction);
mockjs.mock("/dev-api/bigScreen/design/name/repeat", "post", nameRepeatAction);
mockjs.mock(
  "/prod-api/bigScreen/type/list/resourceCatalog",
  "post",
  resourceCatalogAction
);

mockjs.mock("/dev-api/bigScreen/design/add", "post", addDesignAction);
mockjs.mock(
  "/dev-api/bigScreen/permission/check/bigScreen_lxlrujvXkz",
  "get",
  checkPermissionAction
);

mockjs.mock(
  "/dev-api/bigScreen/design/info/code/bigScreen_lxlrujvXkz",
  "get",
  designInfoCode
);

mockjs.mock(
  "/dev-api/bigScreen/chart/data/chart",
  "post",
  chartDataChartAction
);

mockjs.mock("/dev-api/bigScreen/chart/data/list", "post", chartDataListAction);

export default mockjs;
